<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!--_meta 作为公共模版分离出去-->
<!DOCTYPE HTML>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<html>
<head>

    <link rel="stylesheet" type="text/css"
          href="${pageContext.request.contextPath}/assets/H-ui/static/h-ui/css/H-ui.min.css"/>
    <%--引起冲突的样式--%>
    <%--<link rel="stylesheet" href="${pageContext.request.contextPath}/assets/css/table.css"/>--%>
    <link rel="stylesheet" type="text/css"
          href="${pageContext.request.contextPath}/assets/H-ui/lib/Hui-iconfont/1.0.8/iconfont.css"/>
    <link rel="stylesheet" type="text/css"
          href="${pageContext.request.contextPath}/assets/H-ui/static/h-ui.admin/skin/default/skin.css" id="skin"/>
    <link rel="stylesheet" type="text/css"
          href="${pageContext.request.contextPath}/assets/H-ui/static/h-ui.admin/css/style.css"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/assets/css/bootstrap.css"/>
    <!--_footer 作为公共模版分离出去-->
    <script src="${pageContext.request.contextPath}/assets/js/jquery.min.js"></script>
    <script src="${pageContext.request.contextPath}/assets/js/bootstrap.min.js"></script>
    <!--/_footer /作为公共模版分离出去-->
    <title>报告列表管理 - </title>
</head>
<body>
<!--/_menu 作为公共模版分离出去-->
<section class="Hui-article-box">
    <div class="Hui-article">
        <article class="cl pd-20">
            <div class="cl pd-5 bg-1 bk-gray mt-20">
                <div class="mt-20">
                    <h3 align="center">报告项目表</h3>
                    <table class="table table-border table-bordered table-hover table-bg table-sort">
                        <thead>
                        <input id="reportId" value="${sessionScope.reportId}" hidden>
                        <tr class="text-c">
                            <th width="100">报告ID</th>
                            <th width="30">报告项目Id</th>
                            <th width="90">体检项</th>
                            <th width="30">体检费用</th>
                            <th width="30">体检结果</th>
                            <th width="30">状态名</th>
                            <th hidden="hidden"></th>
                            <th hidden="hidden"></th>
                            <th width="100">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <c:if test="${not empty page}">
                            <c:forEach items="${page.list}" var="reportItem">
                                <tr class="text-c">
                                    <td>${reportItem.reportId}</td>
                                    <td>${reportItem.reportItemId}</td>
                                    <td>${reportItem.item.itemName}</td>
                                    <td>${reportItem.item.itemMoney}</td>
                                    <td>${reportItem.item.resultType}</td>
                                    <td hidden>${reportItem.stateId}</td>
                                    <td hidden>${reportItem.item.itemId}</td>
                                    <td>${reportItem.state.stateName}</td>
                                    <c:if test="${reportItem.stateId==16}">
                                        <td class="td-manage">
                                            <a  onclick="balance(this)" class="btn-primary btn-sm">开始体检</a>
                                        </td>
                                    </c:if>
                                    <c:if test="${reportItem.stateId==17}">
                                        <td class="td-manage">
                                            <a href="${pageContext.request.contextPath}/report/upItemState.action?reportItemId=${reportItem.reportItemId}
&itemStateId=${reportItem.stateId}&reportId=${reportItem.reportId}&itemId=${reportItem.item.itemId}&resultType=${reportItem.item.resultType}"
                                               class="btn-primary btn-sm">开始体检</a>
                                        </td>
                                    </c:if>
                                    <c:if test="${reportItem.stateId==18}">
                                        <td class="td-manage">
                                            <a href="${pageContext.request.contextPath}/report/upItemState.action?reportItemId=${reportItem.reportItemId}&itemStateId=${reportItem.stateId}"
                                               class="btn-primary btn-sm">请写小结</a>
                                        </td>
                                    </c:if>
                                    <c:if test="${reprotItem.stateId==19}">
                                        <td class="td-manage">
                                            <a href="javascript" onclick="updateRemark(this)"
                                               class="btn-primary btn-sm">小结详情</a>
                                        </td>
                                    </c:if>
                                </tr>
                            </c:forEach>
                        </c:if>
                        </tbody>
                    </table>
                    <div id="page" style="float: right" align="center">
                        总共${page.pages}页，当前第${page.pageNum}页,每页总共${page.pageSize}。
                        <a id="firstPage" class="btn-sm btn-primary" onclick="changeNum(${page.prePage})">上一页</a>
                        <a id="lastPage" class="btn-sm btn-primary" onclick="changeNum(${page.nextPage})">下一页</a>
                    </div>
                    <div align="center">
                        <input type="button" value="预览">
                        <input type="button" value="打印">
                    </div>
                </div>
            </div>
        </article>


        <div class="modal fade" id="updateModal" style="z-index:99999">
            <div class="modal-dialog" style="width: 600px;z-index: 99999">
                <div class="modal-content">
                    <!-- 模态框头部 -->
                    <div class="modal-header" style="text-align: center;z-index: 1">
                        <label>小结详情</label>
                        <%--<button type="button" class="close" data-dismiss="addModal">&times;</button>--%>
                    </div>
                    <div class="modal-body">
                        <input type="text" hidden name="remarkId1" id="remarkId1">
                        小结内容：<br>
                        <textarea name="remarkField1" style="width: 500px;height: 200px" id="remarkField1"></textarea>
                        <span id="remarkField_input1" style="font-size: 20px;color: red"></span>
                        <br>
                        <br>
                    </div>
                    <div class="modal-footer">
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>
<script type="text/javascript">

    $(function () {
        if (${page.isLastPage}) {
            $("#lastPage").removeAttr("onclick");
        }
    });

    function balance(obj){
        var tds= $(obj).parent().parent().find('td');
        var reportId=tds.eq(0).text();
        var reportItemId=tds.eq(1).text();
        var money=tds.eq(3).text();
        var resultType=tds.eq(4).text();
        var stateId1=Number(tds.eq(5).text());
        var itemId=tds.eq(6).text();
        alert(typeof stateId1);
        var a=1;
        var stateId=stateId1+a;
        $.post("${pageContext.request.contextPath}/report/reportBalance.action",
            {"money":money,"stateId":stateId,"reportItemId":reportItemId},
        function(date){
            if(date==true){
                location.href="${pageContext.request.contextPath}/report/upItemState.action?reportItemId="+reportItemId+"&itemStateId="+stateId+"&reportId="+reportId+"&itemId="+itemId+"&resultType="+resultType
            }else if(date==false){
              alert("提醒用户余额不足");
            }
        })
    }
    function changeNum(obj) {
        var num = obj;
        var reportId = $("#reportId").val();
        window.location.href = "${pageContext.request.contextPath}/report/reportInformation.action?reportId=" + reportId + "&num=" + num;
    }

    function updateRemark(obj) {
        // var tds= $(obj).parent().parent().find('td');
        // $("#remarkId1").val(tds.eq(0).text());
        // $("#remarkField1").val(tds.eq(1).text());
        // $("#remarkName1").val(tds.eq(2).text());
        var remarkField_input1 = $("#remarkField_input1");
        remarkField_input1.text("11111111111");
        $('#updateModal').modal({show: true});
    }

</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>